package com.liu.text;

import com.liu.mapper.StudentMapper;
import com.liu.model.Classs;
import com.liu.model.Student;
import com.liu.utils.mybatisUstils;
import org.apache.ibatis.session.SqlSession;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class mybatisText {
    public static void main(String[] args) throws SQLException {
        SqlSession session = new mybatisUstils().getSession();
        session.getConnection().setAutoCommit(true);
        StudentMapper mapper = session.getMapper(StudentMapper.class);

        Student student1 = new Student();
        student1.setAge(14);
        student1.setName("张可a爱的");
        student1.setClasss(1);
        student1.setSex(0);
        //添加
        //mapper.insetIntoStudent(student1);
       /* List<Student> students = new ArrayList<Student>(5);
        students.add(new Student("张世坤",124,1,16));
        students.add(new Student("卢萨卡",1,0,1));
        students.add(new Student("阿飞",12,1,13));
        students.add(new Student("阿哥",23,0,1));
        students.add(new Student("安徽的",15,1,14));
        mapper.insetIntoStudentlist(students);*/
        //返回id
        //System.out.println("id===="+student1.getId());
        //删除
       // System.out.println(mapper.delectStudentId(13));
        //修改
        //student1.setClasss(12);
        //mapper.updateStudent(student1);
        System.out.println("----------------------------------");
        Classs classs = mapper.selectClassName();
        System.out.println("------------zzzzzzzzzzzzzzzzz----------------------");
        //查询
        /*for (Student student : mapper.selectStudent()) {
            System.out.println(student);
        }*/
        session.close();
    }
}
